﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using dhDataAcess.orderLinqDAL;
using dhDataAcess.Model;
using dhDataAcess.linqDAL;

namespace dhDataAcess.orderDAL
{
   public class colorNumListDAL
    {
         string  tableName = "colorNumList";
        private SqlTransaction tran = null;
        private SqlConnection conn = null;
        public colorNumListDAL(SqlTransaction _transaction, SqlConnection _conn)
        {
            tran = _transaction ;
            conn = _conn;
        }
        /// <summary>
        /// 插入产品信息表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int colorNumListInsert(colorNumListModel row)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            string insertstr = baseBLL.dTableColumnRead.insertSqlStr(tableName).ToString();
            SqlParameter[] para = {
                                        new SqlParameter ("@updateUser",row .updateUser ),
                                        new SqlParameter ("@updateDate",row .updateDate ),
                                        new SqlParameter ("@mark",row .mark ),
                                        new SqlParameter ("@colorNuM",row .colorNuM ),
                                        new SqlParameter ("@colorName",row .colorName ),
                                        new SqlParameter ("@custNum",row .custNum ),
                                        new SqlParameter ("@orderNo",row .orderNo )
                                    };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = insertstr;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
        /// <summary>
        /// 更新产品信息表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int colorNumListUpdate(colorNumListModel row)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
           // string updatestr="update productList set mark=@mark,updateUser=@updateUser,updateDate=@updateDate,createUser=@createUser,createDate=@createDate,pattr=@pattr,pmode=@pmode,ptype=@ptype,pnameMark=@pnameMark,pname=@pname where recordid=@recordid";
          string updatestr = baseBLL.dTableColumnRead.updateSqlStr(tableName).ToString();
          SqlParameter[] para = {
                                        new SqlParameter ("@updateUser",row .updateUser ),
                                        new SqlParameter ("@updateDate",row .updateDate ),
                                        new SqlParameter ("@mark",row .mark ),
                                        new SqlParameter ("@colorNuM",row .colorNuM ),
                                        new SqlParameter ("@colorName",row .colorName ),
                                        new SqlParameter ("@custNum",row .custNum ),
                                        new SqlParameter ("@orderNo",row .orderNo )
                                    };
            cmd.Parameters.AddRange(para);
            cmd.CommandText = updatestr;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
        /// <summary>
        /// 删除一行产品信息表数据
        /// </summary>
        /// <param name="deptRow"></param>
        /// <returns></returns>
        public int colorNumListDel(string recordid)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandType = CommandType.Text;
            string deletestr = baseBLL.dTableColumnRead.delSqlStr (tableName).ToString();
            SqlParameter[] para = {
                                
                                    new SqlParameter ("@recordid",recordid)
                                  }; 
            cmd.Parameters.AddRange(para);
            cmd.CommandText = deletestr ;
            cmd.Transaction = tran;
            int i = cmd.ExecuteNonQuery();
            return i;
        }
    }
}
